package cn.xm.lingshi.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.xm.lingshi.pojo.Shop;
import cn.xm.lingshi.service.ShopService;
import cn.xm.lingshi.service.impl.ShopServiceImpl;

import com.alibaba.fastjson.JSON;

public class ShopTop6Servlet extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	
	public void destroy() {
		super.destroy(); 
		
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		ShopService service=new ShopServiceImpl();
		List<Shop> list=service.printShopListTop6();
		//响应JSON格式的数据
		out.print(JSON.toJSONString(list));
		out.flush();
		out.close();
	}

	
	public void init() throws ServletException {
		
	}

}
